package RemoteCommunication;



import javax.net.ssl.SSLSocket;

import Queue.ACQueue;
import Client.Client;
import Server.Server;

//arrray of this - you can takw over again
public class ForwardClientCmdToLocal {
	//here we will try to create a connetion to a local server, and it will 
	//be refused
	
    //lets test with sepideh beeing a local server
	//the DDNS has to update it will take max 2-3minutes
	//STILL THERE? YH:) THIS IS FUNNY WITH THE REMOTE CONTROL;P
	// I don't know how there can be a fault in my code, though. When it comes to connection refused.
	// It usually means that something went wrong "in the background" 
	//YES, IT CAN POSSIBLE BE LIKE THAT,,,IT WORK NOW,,WICH I GOOD AND STRANGE:)
	//SO WE HAVE TO TEST IT MORE, NOW ITS YOUR TURN YOU WANTED TO WRIGHT SOMETHING?? It's ok. I'm going to go back to what I was doing. Let me know if you need anything.OK, GOOD BY THANKS!No problem
	
	private Client cl;
	private Queue.ACQueue ac;
	private Server send;
	private int houseId;
	private String objectNull="null";
	private String[] commandsHandler={"_","no_command","error","exit"};
	public ForwardClientCmdToLocal(String ip,int port,int houseId){//
		this.houseId=houseId;
		this.objectNull="SERVER";
		cl=new Client(ip,port,"/home/v4h4/git/keystore.jks","password");
		ac = cl.getClientQueue();
		Thread clientThread = new Thread(cl, "ClientThread");
		clientThread.start();
		System.out.println("\n\n\ntrying to connect");
		try{
			Thread.currentThread().sleep(3000);
		}catch(Exception ex){
			
		}
		System.out.println("has connected\n\n\n");
		
	}
	
	public void disConnectLocalServer(){
		//find out;
	}
	
	public void sendCommand(String message){
			cl.setCommand(message);
	}
	
	public String getCommand(){
		return cl.getReply();
	}
	
	public int getHouseId(){
		return this.houseId;
	}
	
}
